package com.ruyuan.eshop.common.framework.monitor;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruyuan.eshop.common.mapper.trade.snapshot.GoodsSnapshotMapper;
import com.ruyuan.eshop.common.model.trade.snapshot.GoodsSnapshot;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *
 * </p>
 *
 * @author pwd
 * @version 1.0
 */
@RestController
@RequestMapping("/monitor")
public class MonitorController {

    @Autowired
    private GoodsSnapshotMapper goodsSnapshotMapper;

    @GetMapping("/f5")
    public MonitorVO f5() {
        // 主要测试能不能正常访问数据库
        QueryWrapper<GoodsSnapshot> queryWrapper = new QueryWrapper<>();
        queryWrapper.last("limit 1");
        GoodsSnapshot goodsSnapshot = goodsSnapshotMapper.selectOne(queryWrapper);
        MonitorVO monitorVO = new MonitorVO();
        if(goodsSnapshot != null) {
            monitorVO.setResult(true);
        } else {
            monitorVO.setResult(false);
        }
        return monitorVO;
    }

}